$(".search_logo").bind({
    mouseenter: function() {
        $(this).css({
            backgroundColor: "#ff6700"
        })
    },
    mouseleave: function() {
        $(this).css({
            backgroundColor: "#ffffff"
        })
    }
})

$(".left_nav_ul").on("mouseenter", "li", function() {
    $(this).children().css({
        display: "block"
    }).parent().siblings().children().css({
        display: "none"
    })
})
$(".left_nav_ul").mouseleave(function() {
    $(this).children().css({
        backgroundColor: "#a4a1a3"
    })
    $(this).children().children().css({
        display: "none"
    })
})

$(".top_left a").hover(
    function() {
        $(this).css({
            color: "#ffffff"
        }).siblings("a").css({
            color: "#b0b0b0"
        })
    }

)

$(".header_nav").mouseenter(function() {
    $(this).children(".header_nav_hide").css({
        height: 240
    })
})
$(".header_nav").mouseleave(function() {
    $(this).children(".header_nav_hide").css({
        height: 0
    })
})

$(".header_nav>li").mouseenter(function() {
    var index = $(this).index()
    $(".header_nav_hide>ul").eq(index).css({
        display: "block"
    }).siblings().css({
        display: "none"
    })
});



$(function() {
    if (getCookie("id")) {
        var name = getCookie("id");
        // console.log(name);
        $(".top_login").children("span").text(name);
        $(".top_login").mouseenter(function() {
            $(this).children("span").text(name).css({
                backgroundColor: "#ffffff",
                color: "#ff7315"
            });
            $(".top_login_hide").css({
                height: 240
            })
        })
        $(".top_login").click(function() {
            location.href = ""
        })
        $(".top_login").mouseleave(function() {
            $(this).children("span").css({
                backgroundColor: "#333333",
                color: "#b0b0b0"
            });
            $(".top_login_hide").css({
                height: 0
            })
        })
    } else {
        $(".top_login_hide").css({
            height: 0
        })
        $(".top_login span").click(function() {
            location.href = "../html/regist.html"
        })
    }
})



$(".exit").click(function() {
    delCookie("id");
})

$(".search_logo").click(function() {
    //  var value1= $("#search").val();

    if ($("#search").val() == "全部商品") {
        location.href = "../html/goodsAll.html"
    } else {
        location.href = "../html/goods_search.html?" + $("#search").val();
    }


})



$.post("../php/topnav_mi_phone.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    var html2 = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`;
        html2 += ` <p data-id="${gid}">
                     <img src="${imgid}" alt=""> <span>${title}</span>                             
                    </p>`
    });
    $(".mi_phone").html(html);
    $(".left_nav_ul_phone div ul").html(html2);

})
$(".mi_phone").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".left_nav_ul_phone div ul").on("click", "p", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})




$.post("../php/topnav_mi_redmi.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `<li data-id="${gid}">
                        <p><img src="${imgid}" alt=""></p>
                        <p>${title}</p>
                        <p>${price}元</p>
                     </li>`
    });
    $(".mi_redmi").html(html);
})
$(".mi_redmi").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})




$.post("../php/topnav_mi_tv.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    var html2 = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`;

        html2 += ` <p data-id="${gid}">
                     <img src="${imgid}" alt=""> <span>${title}</span>                             
                    </p>`
    });
    $(".mi_tv").html(html);
    $(".left_nav_ul_tv div ul").html(html2);

})
$(".mi_tv").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".left_nav_ul_tv div ul").on("click", "p", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})


$.post("../php/topnav_mi_book.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    var html2 = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`;
        html2 += ` <p data-id="${gid}">
                     <img src="${imgid}" alt=""> <span>${title}</span>                             
                    </p>`
    });
    $(".mi_book").html(html);
    $(".left_nav_ul_book div ul").html(html2);
})
$(".mi_book").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".left_nav_ul_book div ul").on("click", "p", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})






$.post("../php/topnav_mi_pad.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`
    });
    $(".mi_pad").html(html);
})
$(".mi_pad").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})

$.post("../php/topnav_mi_jiadian.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    var html2 = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`;
        html2 += ` <p data-id="${gid}">
                     <img src="${imgid}" alt=""> <span>${title}</span>                             
                    </p>`
    });
    $(".mi_jiadian").html(html);
    $(".left_nav_ul_jiadian div ul").html(html2);
})
$(".mi_jiadian").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".left_nav_ul_jiadian div ul").on("click", "p", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})



$.post("../php/topnav_mi_luyouqi.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    var html2 = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}">
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`;
        html2 += ` <p data-id="${gid}">
                     <img src="${imgid}" alt=""> <span>${title}</span>                             
                    </p>`
    });
    $(".mi_luyouqi").html(html);
    $(".left_nav_ul_luyouqi div ul").html(html2);
})
$(".mi_luyouqi").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".left_nav_ul_luyouqi div ul").on("click", "p", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})





$.post("../php/topnav_mi_ai.php", function(data) {
    var result = JSON.parse(data);
    var html = "";
    result.forEach(({
        imgid,
        title,
        price,
        gid
    }) => {
        html += `  <li data-id="${gid}"> 
                            <p><img src="${imgid}" alt=""></p>
                            <p>${title}</p>
                            <p>${price}元</p>
                        </li>`
    });
    $(".mi_ai").html(html);
})
$(".mi_ai").on("click", "li", function() {
    var gid = $(this).attr("data-id");
    location.href = "../html/detail.html?gid=" + gid;
})
$(".lunbo1").click(function() {
    location.href = "../html/detail.html?gid=3000000002";
})
$(".lunbo2").click(function() {
    location.href = "../html/detail.html?gid=1194400088";
})
$(".lunbo3").click(function() {
    location.href = "../html/detail.html?gid=3000000003";
})
$(".lunbo5").click(function() {
    location.href = "../html/detail.html?gid=3000000004";
})
$(".lunbo6").click(function() {
    location.href = "../html/detail.html?gid=3000000000";
})
$(".banner_bottom_right_first").click(function() {
    location.href = "../html/detail.html?gid=3000000005";
})
$(".banner_bottom_right_second").click(function() {
    location.href = "../html/detail.html?gid=3000000007";
})
$(".banner_bottom_right_third").click(function() {
    location.href = "../html/detail.html?gid=3000000006";
})